package cn.sfa.common.taglib;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;

import cn.sfa.entity.system.BranchSysCode;
import cn.sfa.entity.system.FunctionSysCode;
import cn.sfa.entity.system.ModelSysCode;
import cn.sfa.entity.system.ProviderSysCode;

/**
 * 
 * 类名称：BranchService 类描述： 机构信息service类 创建人：lenovo 创建时间：2012-3-6 上午10:49:56
 * 修改人：lenovo 修改时间：2012-3-6 上午10:49:56 修改备注：
 * 
 * @version
 */
public class CommonService {

	Logger log = LoggerFactory.getLogger(CommonService.class);

	private NamedParameterJdbcTemplate jdbcTemplate;

	public NamedParameterJdbcTemplate getJdbcTemplate() {
		return jdbcTemplate;
	}

	public void setJdbcTemplate(NamedParameterJdbcTemplate jdbcTemplate) {
		this.jdbcTemplate = jdbcTemplate;
	}

	public List<FunctionSysCode> getFunctionList() {
		String sql = "select f.moduleid,g.salefuncid,g.funcurl,g.funcname,f.modulename,g.parentfunid " +
				"from salemodulefunction e,salemodule f,salefunction g"+
				" where e.salemoduleid=f.moduleid"+
				" and e.salefunctionid=g.salefuncid order by g.integerposition asc";

		return jdbcTemplate.getJdbcOperations().query(
				sql,
				new BeanPropertyRowMapper<FunctionSysCode>(
						FunctionSysCode.class));
	}

	public List<ModelSysCode> getModelList() {
		String sql = "select b.saleroleid,c.moduleid,c.defaulturl,c.modulename,b.rolename,c.parentmoduleid,c.modulelevel from" +
				" salerolemodule a,salerole b,salemodule c"+
				" where a.saleroleid=b.saleroleid"+ 
				" and   a.salemoduleid=c.moduleid order by c.viewseqno asc";

		return jdbcTemplate.getJdbcOperations().query(
				sql,
				new BeanPropertyRowMapper<ModelSysCode>(
						ModelSysCode.class));
	}
}
